<?php

class Module_Impl_User_Opration extends Module_Impl_Abstarct_Opration   {
	
	protected $_tablename = Config_Table::TABLE_USER;	
	protected $_objectname = "Object_User";

	protected $_check_field_before_insert = array(
				'username'=>'user.register.fail.user.exist',
	            'email'=>'user.register.fail.email.exist'
	          );
	
	
	const FAIL_TO_UPDATE_BECAUSE_NO_EXIST = 'user.update.fail.no.exist';
	const FAIL_TO_DELETE_BECAUSE_NO_EXIST = 'user.delete.fail.no.exist';
	
	protected function __construct() {
		parent::__construct ();	
		$this->_interface_select = Module_Impl_User_Select::getInstance();
	}
	/**
	 * Singleton instance
	 * @var Module_Impl_User_Opration
	 */
	protected static $_instance = null;
	/**
	 * Singleton instance 
	 * @return Module_Impl_User_Opration
	 */
	public static function getInstance() {
		if (null === self::$_instance) {
			self::$_instance = new self ( );
		}
		return self::$_instance;
	}
	
	public function insert($info){	
		if((!isset($info ['nickname']) or empty($info ['nickname']))and isset($info ['username']) ){
			$info ['nickname'] = $info ['username'];
		}
		return parent::insert($info);
	}	
}